package com.sylar.happygps;

import com.sylar.happygps.adapter.LifeGridAdapter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.TextView;

public class LifeActivity extends Activity implements OnClickListener,OnItemClickListener{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.life);
		
		Button btn_title_left = (Button) findViewById(R.id.btn_title_left);
		btn_title_left.setText(R.string.app_name);
		btn_title_left.setVisibility(View.VISIBLE);
		btn_title_left.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		TextView tv_title_name = (TextView) findViewById(R.id.tv_title_name);
		tv_title_name.setText("生活服务");
		
		GridView life_grid = (GridView) findViewById(R.id.life_grid);
		LifeGridAdapter adapter = new LifeGridAdapter(this);
		life_grid.setAdapter(adapter);
		life_grid.setOnItemClickListener(this);
		
//		View tv_fantong = findViewById(R.id.tv_fantong);
//		View tv_world = findViewById(R.id.tv_world);
//		View tv_ctrip = findViewById(R.id.tv_ctrip);
//		
//		tv_fantong.setOnClickListener(this);
//		tv_world.setOnClickListener(this);
//		tv_ctrip.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
//		case R.id.tv_fantong:
//			toFantong();
//			break;
//		case R.id.tv_world:
//			toWorld();
//			break;
//		case R.id.tv_ctrip:
//			toCtrip();
//			break;

		}
	}
	
	private void toFantong(){
		Intent intent = new Intent(this,WebActivity.class);
		intent.putExtra("openurl", "http://www.fantong.com");
		startActivity(intent);
	}
	private void toWorld(){
		Intent intent = new Intent(this,WebActivity.class);
		intent.putExtra("openurl", "http://www.youtx.com/");
		startActivity(intent);
	}
	private void toCtrip(){
		Intent intent = new Intent(this,WebActivity.class);
		intent.putExtra("openurl", "http://www.ctrip.com");
		startActivity(intent);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		toCtrip();
	}
	
}
